<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8" import="java.util.List,com.student.entity.*"%>
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fns" uri="/WEB-INF/tld/fns.tld" %>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>学生列表</title>
	<c:set var = "path" value = "${pageContext.servletContext.contextPath }"></c:set>
	<link rel="stylesheet" type="text/css" href="${path }/dist/css/bootstrap.min.css"/>
	<link rel="stylesheet" type="text/css" href="${path }/css/update.css"/>
	<link rel="stylesheet" type="text/css" href="${path }/css/bootstrap-datetimepicker.min.css"/>
</head>
<body>

	<!-- 页面导航开始 -->
	<jsp:include page="/WEB-INF/page/header.jsp"></jsp:include>
	<!-- 页面导航结束 -->

	<div id = "studentList">
	<div class="container">
		<ol class="breadcrumb">
			<li><a href="#">学生信息</a></li>
			<li><a href="#">2018</a></li>
			<li class="active">9月</li>
		</ol>
	</div>

	<div class="container">
		<div>
			<form action="${path }/student/list" class="bs-example bs-example-form" role="form">
				<div class="row">
					<div class="col-md-3">
						<div class="input-group">
							<input type="hidden" id="uname" name="uname"> 
							<input type="text" name="likename" value=""  placeholder="学生姓名进行模糊查询" class="form-control"> 
							<span class="input-group-btn">
								<button class="btn btn-default" type="submit">查询</button>
							</span>
						</div>
					</div>
					<div class="col-md-4">
						<button  class="btn btn-danger" type="button" onclick="delStu()">删除学生</button>
						<a href="${path }/student/form" class="btn btn-info">添加</a>
						<%-- <a href="${path }/student/showStudent" class="btn btn-warning">查看详情</a> --%>
					</div>
				</div>
			</form>
		</div>
	</div>

	<div class="container">
		<div class="table-responsive">
			<table class="table table-hover">
				<caption>全部学生信息</caption>
				<thead>
					<tr class="active">
						<th><input type="checkbox" onclick="checkAll(this)" /></th>
						<th>姓名</th>
						<th>学号</th>
						<th>性别</th>
						<th>出生日期</th>
						<th>政治面貌</th>
						<th>简介</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					
						<c:forEach items="${list }" var="student">
							<tr>
								<td><input type="checkbox" value="${student.id }" name="cks" /></td>
								<td><a href="${path }/student/showStudent?id=${student.id}">${student.sname }</a></td>
								<td>${student.studentNumber }</td>
								<td><fmt:formatDate value="${student.birthday }" pattern="yyyy-MM-dd" /></td>
								<td>${student.sex == 1? "男" : "女"}</td>
								<td>${student.polity == 1? "党员":student.polity == 2? "团员" :student.polity == 3? "无党派" :"其他"}</td>
								<td>${student.brief }</td>
								<td><a href="${path }/student/form?id=${student.id}" class="btn btn-warning">修改</a></td>
							</tr>
						</c:forEach>
						
					
				</tbody>
			</table>
		</div>
	</div>
</div>
	<div class="container">
		<div class="row text-center">
			<div class="col-md-12">
				<ul class="pagination">
					<li><a href="${path }/student/list?page=1&likename=${likename }" class="${currentPage eq 1 ? 'btn disabled' : '' }"  >首页</a></li>
					<li><a class="${currentPage eq 1 ? 'btn disabled' : '' }" href="${path }/student/list?page=${currentPage - 1}&likename=${likename }">&laquo;</a></li>
					<c:forEach begin="1" end="${totalPage }" var="page">
					<li class="${page eq currentPage ? 'active' : '' }"><a href="${path }/student/list?page=${page}&likename=${likename }">${page }</a></li>
					</c:forEach>
					<li><a href="${path }/student/list?page=${currentPage + 1}&likename=${likename }" class="${currentPage eq totalPage ? 'btn disabled' : '' }"  >&raquo;</a></li>
					<li><a class="${currentPage eq totalPage ? 'btn disabled' : '' }" href="${path }/student/list?page=${totalPage}&likename=${likename }" style="border: 1px solid #ddd;">尾页</a></li>
					<li><a style="border: 0px;margin-left: 0px;">当前页${currentPage }/${totalPage }总页</a></li>
				</ul>
			</div>
		</div>
	</div>
	<script type="text/javascript" src="${path }/js/jquery.min.js"></script>
	<script type="text/javascript" src="${path }/dist/js/bootstrap.min.js"></script>
	<script type="text/javascript">
	function delStu(){
		//获取当前登录的用户名称
		//var uname = document.getElementById("uname").value;
		
		//1.确定是否勾选了
		var count = 0;
		
		//定义一个变量,用来拼接checkbox的value
		var sids="";
		
		//1.获取所有的td中的checkbox
		var cks = document.getElementsByName("cks");
		
		//2.遍历
		for(var i=0;i<cks.length;i++){
			if(cks[i].checked){
				count++;
				sids+=cks[i].value+",";
			}
		}
		//3.判断...
		if(count==0){
			//说明没有勾选的.
			alert("对不起!请您先选择需要删除的学生信息!");
			return;
		}
		
		//4.选了.
		var flag = window.confirm("确定删除吗?");//返回是true-确定
		//5.判断
		if(flag){
			//发送到删除学生的action
			window.location.href='/studentSystems/student/delete?sids=' + sids.substring(0,sids.length-1);
		}
	}
	</script>
</body>
</html>